package com.yoomiito.app.ui.live;

import androidx.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yoomiito.app.R;
import com.yoomiito.app.model.bean.LiveInfo;
import com.yoomiito.app.utils.ImageLoader;

import java.util.List;

public class LiveAdapter extends BaseQuickAdapter <LiveInfo, BaseViewHolder>{

    public LiveAdapter(@Nullable List<LiveInfo> data) {
        super(R.layout.item_live,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, LiveInfo item) {
        ImageView iv = helper.getView(R.id.item_live_iv);
        TextView statusTv = helper.getView(R.id.item_live_status);
        TextView nameTv = helper.getView(R.id.item_live_name);
        TextView typeTv = helper.getView(R.id.item_live_type);

        ImageLoader.getInstance().into(iv.getContext(),item.getCover_pic(),iv,R.drawable.goods_default);
        statusTv.setText(getStatus(item));
        nameTv.setText(item.getName());
        typeTv.setText(item.getTitle());
    }

    private String getStatus(LiveInfo item){
        if (item.getState()==1){
            return "正在直播";
        }else {
//            if (1==item.getHas_video()){
//                return "回放";
//            }
            return "未开播";
        }
    }
}
